package com.wc.fortnight_blue_bridge.Q250405.蓝桥速算;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/4/5 19:40
 * @description
 * https://www.lanqiao.cn/problems/20290/learning/?contest_id=253
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static long[] d = new long[N];
    // a 记录奇数位置要操作的次数, b 记录偶数要操作的次数
    static long[] a = new long[N], b = new long[N];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 1; i <= n; i++) d[i] = sc.nextInt();
        while (m-- > 0) {
            int l = sc.nextInt(), r = sc.nextInt();
            int x = -1;
            if ((l & 1) == 1) x = 1;
            a[l] += x;
            a[r + 1] -= x;
            b[l] += -x;
            b[r + 1] -= -x;
        }
        for (int i = 1; i <= n; i++) a[i] += a[i - 1];
        for (int i = 1; i <= n; i++) b[i] += b[i - 1];
        for (int i = 1; i <= n; i++) {
            if ((i & 1) == 1) d[i] += a[i] * i;
            else d[i] += b[i] * i;
        }
        for (int i = 1; i <= n; i++) d[i] += d[i - 1];

        out.println(d[n]);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

